<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{asset('/css/web/login/inc.css')}}">
    <link rel="stylesheet" href="{{asset('/css/web/login/login.css')}}">
    <link rel="stylesheet" href="{{asset('/css/web/login/register.css')}}">
    <link rel="stylesheet" href="{{asset('/css/web/login/forget.css')}}">
    <script src="{{mix('/js/web/frame/distpicker.js')}}"></script>
</head>

<body class="pro">
<div class="register_maim">
    <div class="w1200">
        <div class="header">
            <a class="logo fl" href="{{asset('/')}}">
                <img src="{{asset('/img/web/login/r_logo.png')}}" alt="">
            </a>
            <div class="header_right">
                <a class="back" href="{{asset('/')}}">返回官网</a><span>|</span><p class="have">已有账号？<a class="login" href="">快速登录</a></p>
            </div>
        </div>
        <div class="company_reg">
            <ul class="reg_second">
                <li class="flow one">填写账号</li>
                <li class="flow one">完善信息</li>
                <li class="flow third">完成注册</li>
            </ul>
        </div>
        <div class="register_box">
             <div class="perfect">
                <form action="{{asset('/user/companyregister')}}" method="post" id="business-post">
                    <input  type="hidden" name='pwd' value="{{$pwd}}" >
                    <input  type="hidden" name='phone' value="{{$phone}}" >
                    <input  type="hidden" name='personal_enterprise' value="{{$personal_enterprise}}" >
                    <div class="row">
                        <div class="tit mt25"><span>单位名称</span></div>
                        <div class="perfect_box mt25 input_error">
                            <input class="w268" type="text" name='name' id="name" value="">
                            <span class="jm_error"></span>
                        </div>
                    </div>
                    <div class="row">
                        <div class="tit mt25"><span>组织机构代码</span></div>
                        <div class="perfect_box mt25 input_error">
                            <input class="w268" type="text" name='organizationCode' id="organizationCode">
                            <span class="jm_error"></span>
                        </div>
                    </div>
                    <div class="row">
                        <div class="tit mt25"><span>公司类型</span><br><span class="more">(可多选)</span></div>
                        <div class="perfect_box mt25 company_type">
                            <span data-id="制造企业" class="dq">制造企业</span>
                            <span data-id="分销代理商">分销代理商</span>
                            <span data-id="工程公司">工程公司</span>
                            <span data-id="系统集成商">系统集成商</span>
                            <span data-id="地产物业公司">地产物业公司</span>
                            <span data-id="事业单位">事业单位</span>
                            <span data-id="政府机关">政府机关</span>
                            <span data-id="其他">其他</span>
                            <input type="hidden" name='company_type' id="company_type" value="制造企业">
                            <div class="jm_error"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="tit mt25"><span>所在地</span></div>
                        <div class="perfect_box mt25 input_error">
                            <div id="distpicker">
                                <select class="province" name="province_id">
                                    <option>选择省份</option>
                                </select>
                                <input type="hidden" name="province_text" id="province_text">
                                <select class="city" name="city_id">
                                    <option>选择城市</option>
                                </select>
                                <!-- <input type="text" name="address" class="address" required value="{{!empty($item_clone)?$item_clone['project_addr']:''}}" placeholder="请输入详细地址"> -->
                                <input type="hidden" name="city_text" id="city_text">
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        {{ csrf_field() }}
                        <div class="btn_sub" id="business_register">下一步</div>
                    </div>
                    <div class="row">
                        <p class="use">e井在线承诺上述信息仅用作用户真实身份核实</p>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
$(function() {
    //城市
    var province = "";
    var city = "";
    $('#distpicker').distpicker({
        province: province,
        city: city
    });
    $('.province').change(function(){
        var province_text=$(".province option:selected").text();
        $('#province_text').val(province_text);
    });
    $('.city').change(function(){
        var city_text=$(".city option:selected").text();
        $('#city_text').val(city_text);
    });
    //公司类型
    $('.company_type span').click(function(){
        if($(this).hasClass('dq')){
            $(this).removeClass("dq");
        }else{
            $(this).addClass("dq");
        }
        var company_type = [];
        $(".company_type .dq").each(function(i){
            company_type.push($(this).attr('data-id'));
        });
        $('#company_type').val(company_type);
    });
    $('#business_register').click(function(){
        var regEn = /[`~!@#$%^&*()……_+<>?:"{},.\/;'[\]]/im,
            regCn = /[·！#￥（——）：；“”‘、，|《。》？、【】[\]]/im;
        // var code = /^[a-zA-Z0-9]{8}-[a-zA-Z0-9]$/;
        $('.jm_error').html('');
        $('.input_error').removeClass('jm_input_error');
        // 单位名称
        var name = $("input[name='name']").val();
        if ($.trim(name) == '') {
            $('input[name="name"]').next().html('请输入单位名称');
            $('input[name="name"]').parent('.input_error').addClass('jm_input_error');
            return false;
        }
        if (regEn.test(name) || regCn.test(name)) {
            $('input[name="name"]').next().html('请不要输入非法字符');
            $('input[name="name"]').parent('.input_error').addClass('jm_input_error');
            return false;
        }
        if ($.trim(name).length > 26) {
            $('input[name="name"]').next().html('输入单位名称过长');
            $('input[name="name"]').parent('.input_error').addClass('jm_input_error');
            return false;
        }
        var organizationCode = $("input[name='organizationCode']").val();
        if ($.trim(organizationCode) == '') {
            $('input[name="organizationCode"]').next().html('请输入组织机构代码');
            $('input[name="organizationCode"]').parent('.input_error').addClass('jm_input_error');
            return false;
        }
        if (regEn.test(organizationCode) || regCn.test(organizationCode)) {
            $('input[name="organizationCode"]').next().html('请不要输入非法字符');
            $('input[name="organizationCode"]').parent('.input_error').addClass('jm_input_error');
            return false;
        }
        if ($.trim(organizationCode).length > 20) {
            $('input[name="organizationCode"]').next().html('输入组织机构代码字符过多');
            $('input[name="organizationCode"]').parent('.input_error').addClass('jm_input_error');
            return false;
        }
        // if(!code.test(organizationCode)) {
        //     $('input[name="organizationCode"]').next().html('组织机构代码只能输入字母或数字！');
        //     $('input[name="organizationCode"]').parent('.input_error').addClass('jm_input_error');
        //     return false;
        // }

        // 公司类型
        var company_type = [];
        $(".company_type .dq").each(function(i){
            company_type.push($(this).attr('data-id'));
        });
        $('#company_type').val(company_type);
        var company_type=$('input[name="company_type"]').val();
        if (company_type == '') {
            $('input[name="company_type"]').next().html('请选择公司类型');
            return false;
        }
        //省
        var province = $(".province option:selected").text();
        if (province == '请选择省份') {
            layer.alert("请选择项目地点省份!",{icon: 0});
            return false;
        }
        //市
        var city = $(".city option:selected").text();
        if (city == '请选择城市') {
            layer.alert("请选择项目地点城市!",{icon: 0});
            return false;
        }
        //ajax提交验证
        $.ajax({
            url: $("#business-post").attr('action'),
            type: 'POST',
            dataType: 'json',
            data: $("#business-post").serializeArray(),
            success: function (data) {
                if (data.code == 0) {
                    window.location.href = AJAX_URL + '/user/companyregisterthree';
                } else {
                    layer.alert(data.message, {
                        icon: 0
                    });
                }
            }

        })
        return false;
    });
})
</script>
</body>
</html>